<h2>Sizing Your HelioMaxx Solar Hot Water Kit:</h2>

	<?php
		$climate = $_GET['climate'];
		$people = $_GET['people'];
	?>

	<div style="width:940px;margin-left:auto;margin-right:auto;">

	<p style="text-align:center;"><img src="http://www.sunmaxxsolar.com/wp-content/uploads/2013/08/residential-shw-sizing-process.jpg" alt="How To Order Residential Solar Hot Water Systems" style="margin-bottom:20px;" /></p>
        
	<div style="width:100%;height:0px;clear:both;"></div>
        
		<div style="width:600px;float:left;margin:0px;margin-right:40px;">
			<img src="http://www.sunmaxxsolar.com/wp-content/themes/SunMaxxSolar/images/ppkits-warmvcoldmap.jpg" alt="Residential Solar Hot Water Sizing Map" style="width:600px;float:right;margin:0px;" />
			
            <?php if ($climate != '0' && $climate != '') { ?>
            	<img src="http://www.sunmaxxsolar.com/wp-content/themes/SunMaxxSolar/images/singlearrow-orange.png" alt="Residential Solar Hot Water Sizing Banner" style="width:600px;float:right;margin:0px;" />
			<?php } ?>
		</div>

		<div style="width:300px;float:left;margin:0px;">
			<?php echo do_shortcode('[jazzy form="residentialkitsizing"]'); ?>
		</div>
    
		<div style="width:100%;height:0px;clear:both;"></div>
        
        <?php
			
			if($climate != '0' && $climate != '') {
				
				// ESTABLISH BASE VALUES BASED ON CLIMATE
				if($climate == 'Cold') {
					$base_btu_needed_day = 584;
					$kit_climate_type = 'cold';
					$collector_climate = 'cold_btu';
				}
	
				if($climate == 'Warm') {
					$base_btu_needed_day = 417;
					$kit_climate_type = 'warm';
					$collector_climate = 'warm_btu';
						$collector_btu = get_field('collector_warm_btu');
				}
	
				// ESTABLISH KIT SIZES BASED ON PEOPLE
				if($people == 1 || $people == 2) {
					$kit_size = 50;	
				} elseif ($people == 3 || $people == 4) {
					$kit_size = 80;
				} elseif ($people == 5 || $people == 6) {
					$kit_size = 120;
				} elseif ($people == 7 || $people == 8) {
					$kit_size = 160;
				}
				
				// ESTABLISH PEOPLE SERVED VARIABLES
				if($kit_size == 50) {
					$peopleserved = '1-2';
				} elseif($kit_size == 80) {
					$peopleserved = '1-4';
				} elseif($kit_size == 120) {
					$peopleserved = '5-6';
				} elseif($kit_size == 160) {
					$peopleserved = '7-8';
				}
	
				// ESTABLISH TOTAL BTU NEEDED PER DAY ( base_btu_needed_day x $kit_size )
				$kit_btu_needed_day = $base_btu_needed_day * $kit_size;
				
		?>
        
        	<a name="yourkits">&nbsp;</a>
        	<h3>1. Your Recommended Solar Kits</h3>
            <table class="models" cellpadding="0" cellspacing="0" style="width:100%;border:0px;">
            
            	<tr>
                	<th style="height:40px;line-height:40px;font-weight:bold;background:#f2f2f2;text-align:left;padding-left:10px;">Kit SKU</th>
                    <th style="height:40px;line-height:40px;font-weight:bold;background:#f2f2f2;text-align:right;">Kit / Tank Type</th>
                    <th style="height:40px;line-height:40px;font-weight:bold;background:#f2f2f2;text-align:right;">Kit Capacity</th>
                    <th style="height:40px;line-height:40px;font-weight:bold;background:#f2f2f2;text-align:right;">People Served</th>
                    <th style="height:40px;line-height:40px;font-weight:bold;background:#f2f2f2;text-align:right;padding-right:10px;">Pricing &amp; Buy Today</th>
                </tr>
                
                <?php // QUERY PRE-PACKAGED KITS
					$args = array(
						'post_type' => 'product',
						'meta_query' => array(
								array(
									'key' => 'shw_kit_climate',
									'value' => array('both', ''.$climate.''),
									'compare' => 'IN'
								),
								array(
									'key' => 'shw_kit_capacity',
									'value' => ''.$kit_size.'',
									'compare' => '=='
								)
						)
					);

					$productdocuments = new wp_query($args);
					while($productdocuments->have_posts()) : $productdocuments->the_post();
					
						$productsku = get_post_meta($post->ID, '_sku', true);
						global $product;
				?>
                
						<tr>
							<td style="text-align:left;padding-left:10px;"><a href="<?php the_permalink(); ?>" style="color:#002d55;text-decoration:none;"><?php echo $product->sku; ?></a> <?php if(is_single(array( 13018, 13019 ))) {?><em>(Collectors Included)</em><?php } else { ?><em>(Add Collectors Below)</em><?php } ?></td>
                            <td style="text-align:right;"><?php the_field('shw_kit_type'); ?></td>
                            <td style="text-align:right;"><?php the_field('shw_kit_capacity'); ?></td>
                            <td style="text-align:right;"><?php echo $peopleserved ; ?></td>
                            <td style="text-align:right;padding-right:10px;"><?php include '/home/sunmaxxs/public_html/wp-content/themes/SunMaxxSolar/woocommerce/single-product/add-to-cart/simple.php' ; ?></td>
						</tr>
                        
				<?php
					endwhile;
					wp_reset_query();
				?>
            
            </table>
            
            <h3>2. Add Your Solar Collectors</h3>
            <table class="models" cellpadding="0" cellspacing="0" style="width:100%;border:0px;">
            
            	<tr>
                	<th style="height:40px;line-height:40px;font-weight:bold;background:#f2f2f2;text-align:left;padding-left:10px;">SKU / Model</th>
                    <th style="height:40px;line-height:40px;font-weight:bold;background:#f2f2f2;text-align:right;">Collector Type</th>
                    <th style="height:40px;line-height:40px;font-weight:bold;background:#f2f2f2;text-align:right;">Recommended Qty</th>
                    <th style="height:40px;line-height:40px;font-weight:bold;background:#f2f2f2;text-align:right;padding-right:10px;">Pricing &amp; Buy Today</th>
                </tr>
                
                <?php // QUERY SOLAR COLLECTORS
					$args = array(
						'post_type' => 'product',
						'meta_query' => array(
								array(
									'key' => 'collector_for_kits',
									'value' => 'No',
									'compare' => '!='
								)
						)
					);

					$productdocuments = new wp_query($args);
					while($productdocuments->have_posts()) : $productdocuments->the_post();
					
						$productsku = get_post_meta($post->ID, '_sku', true);
						if($climate == 'Cold') {
							$collector_btu = (get_field('collector_cold_btu')*1.2);
						} elseif($climate == 'Warm') {
							$collector_btu = (get_field('collector_warm_btu')*1.2);
						}
						
						$collectorqty = $kit_btu_needed_day / $collector_btu;
						global $product;
				?>
                
                <tr>
                	<td style="text-align:left;padding-left:10px;"><a href="<?php the_permalink(); ?>" style="color:#002d55;text-decoration:none;"><?php echo $product->sku; ?></a></td>
                    <td style="text-align:right;"><?php the_field('collector_type'); ?></td>
                    <td style="text-align:right;"><?php echo round($collectorqty) ; ?></td>
                    <td style="text-align:right;padding-right:10px;"><?php include '/home/sunmaxxs/public_html/wp-content/themes/SunMaxxSolar/woocommerce/single-product/add-to-cart/simple.php' ; ?></td>
                </tr>
                
                <?php
					endwhile;
					wp_reset_query();
				?>
                
			</table>
        
        <?php } ?>
        
        <div style="width:100%;height:0px;clear:both;"></div>

    </div>

<div style="width:100%;height:1px;background:#cccccc;clear:both;margin-top:20px;margin-bottom:20px;"></div>